﻿@using DevExpress.Blazor
@using DevExpress.ExpressApp.Blazor.Components
@using EasyXaf.LowCode.WorkflowEditors.Models
@using EasyXaf.LowCode.WorkflowEditors.Models.Activities;
@using Microsoft.AspNetCore.Components.Web

<div class="workflow-toolbar">
    <DxToolbar>
        <Items>
            <DxToolbarItem>
                <Template>
                    <div class="workflow-container-navigation">
                        @foreach (var container in GetContainers())
                        {
                            var caption = container is IWorkflow ? "首页" : ((IContainerActivity)container).Caption;
                            var imageName = container is IWorkflow ? "Actions_Home" : ((IContainerActivity)container).ImageName;
                            <div class="container-item @(container==Container?"current-item":"")" @onclick="async()=>await ChangeContainerAsync(container)">
                                <XafImage ImageName="@imageName" Size="16" Color="#7F8C8D" />
                                <span class="container-text">@caption</span>
                            </div>
                            if (container != Container)
                            {
                                <span class="px-1 m-auto"> > </span>
                            }
                        }
                    </div>
                </Template>
            </DxToolbarItem>
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("Actions_Undo")" Enabled="UndoManager.CanUndo" BeginGroup="true" Click="Undo" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("Actions_Redo")" Enabled="UndoManager.CanRedo" Click="Redo" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("BestFit")" BeginGroup="true" Click="BestFit" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("FitToDrawing")" Click="FitToDrawing" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("ZoomIn")" BeginGroup="true" Click="ZoomInAsync" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" CssClass="workflow-canvas-zoom-value" Text="@($"{(int)(Zoom * 100)}%")" Click="async()=>await ZoomAsync(1)" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("ZoomOut")" Click="ZoomOutAsync" />
            <DxToolbarItem Alignment="ToolbarItemAlignment.Right" IconUrl="@ImageUrlService.GetImageUrl("PanAndZoomPanel")" Checked="PanAndZoomPanelVisible" BeginGroup="true" Click="HandlePanAndZoomPanelVisible" />
        </Items>
    </DxToolbar>
</div>
